﻿
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using FDEECommonTools;
using FDEEInterface;
using FDEEPublicFunc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FDEEDrawingModels
{
    public class DrawingRampPlinthList
    {
        public static void DrawRampPlinthBatch(Database db, string dwgPath, string plinthCoorPath, string blockParaPath,int stNo,int endNo, string pierList, string tAPara, string tBPara, string iAPara, string iBPara,ref string pierdiv, string title = "MAINLINE",string tkPath="",bool isPositive=false)
        {
            double scale = 1;
           Extents2d ext = new Extents2d(Point2d.Origin, Point2d.Origin);
            Extents2d extA = new Extents2d(Point2d.Origin, Point2d.Origin);
            Extents2d extB = new Extents2d(Point2d.Origin, Point2d.Origin);
            Extents2d extC = new Extents2d(Point2d.Origin, Point2d.Origin);
            Point2d CT = Point2d.Origin.Convert2D(0, -2 * scale);
            Point2d M1 = CT;
            ext = new Extents2d(M1, M1);
            System.Data.DataTable dtA = new System.Data.DataTable();
            System.Data.DataTable dtB = new System.Data.DataTable();
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Desktop\FDEE_Data\295~335参数表.csv");

            //System.Data.DataTable dt =new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(@"C:\Users\huajie\Desktop\FDEE_Data\Banani参数表.xlsx");
            System.Data.DataTable dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(blockParaPath);
            int i = 0;
            int pageNo = 1;
            if (dt.Rows.Count > 0)
            {

                for (int m = stNo; m <= endNo; m++)
                {
                    pierdiv = dt.Rows[stNo]["墩号"].ToString() + "-" + dt.Rows[endNo]["墩号"].ToString();
                    double side = double.Parse(dt.Rows[m]["左边距"].ToString());
                    double rside = double.Parse(dt.Rows[m]["右边距"].ToString());
                    double width = double.Parse(dt.Rows[m]["总墩距"].ToString()) + rside + side;
                    string piertype = dt.Rows[m]["墩柱类别"].ToString();
                    string piername = dt.Rows[m]["墩号"].ToString();
                    if (width > 12)
                        scale = 80;
                    else  if (width > 26)
                        scale = 100;
                    else
                        scale = 40;
                    double height = double.Parse(dt.Rows[m]["总高"].ToString());
                    if (height >= 3)
                    {
                        if (width > 12)
                            scale = 120;
                        else
                            scale = 80;
                    }
                    else if (height >= 2)
                        scale = 80;
                    ext = new Extents2d(M1.Convert2D(420 * i, -297), M1.Convert2D(420 * i, -297));
                    extA = new Extents2d(M1.Convert2D(420 * i, -297 - 10), M1.Convert2D(420 * i, -297 - 10));
                    extB = new Extents2d(M1.Convert2D(420 * i, -297 - 30), M1.Convert2D(420 * i, -297 - 30));
                    extC = new Extents2d(M1.Convert2D(420 * i, -297 - 30 - 10), M1.Convert2D(420 * i, -297 - 30 - 10));
                    DrawingPlinth(db, ref ext, ref extA, ref extB, ref extC, M1.Convert3D(420 * i, -297), M1.Convert3D(420 * i, -297 - 10), M1.Convert3D(420 * i, -297 - 30), M1.Convert3D(420 * i, -297 - 30 - 10),
                        Extensions.curFont, scale, dt.Rows[m], dwgPath,  plinthCoorPath,  tAPara,  tBPara,  iAPara,  iBPara, title,isPositive);
                    string content = "Notes:\\P"
+ "1. All dimensions are in m unless otherwise indicated.\\P"
+ "2. The contractor shall verify all dimensions on site and resolve all discrepancies with the \\P engineer & architect before commencement of work."
+ "3. All the produced unsuitable material shall be transport to the designate disposal area in a properly manner.\\P"
+ "4. All the site activities and operations shall follow the requirement of the approved Health and Safety \\P Management Plan strictly."
+ "5. Concrete shall have the minimum 45MPa of cylinder compressive strength at 28 days.\\P"
+ "6. Reinforcement steel shall have the minimum yield strength 500MPa.\\P"
+ "7. Concrete cover shall be 0.050m for cross beam.";

                    for (int n = 0; n < pageNo; n++)
                    {

                        Extents2d ext0 = new Extents2d(Point2d.Origin, Point2d.Origin);
                        //if (n < pageNo - 1)
                        //{
                        //    Common.CreatPlinthLayoutNew(db, "垫石构造", ext, extA, scale, pageNo - 1, i, n);
                        //}
                        //else
                        //{
                        //    Common.CreatPlinthLayoutNew(db, "垫石构造", extB, extC, scale, 1, i, n);
                        //}
                        Common.CreatRampPlinthLayoutNew(db, "盖梁构造", ext, extA, extB, extC, scale, 1, i, n,false, tkPath);
                        //string _blcName = piertype;
                        //db.CopyBlockFromFile(dwgPath, _blcName);
                        //BlockTool.InsertBlockReference(Point2d.Origin.Convert3D(17.85 + 420 * n, 23.3 - 297 * i), 1, _blcName, dwgPath, 0, false);
                        //Extents2d ext0 = new Extents2d(Point2d.Origin, Point2d.Origin);
                        TextPloter.PrintMultiText(db, ref ext0, Point2d.Origin.Convert3D(17.85 + 260 + 420 * n, 23.3 + 108 - 297 * i), content, 1, 3, 130, false);
                    }
                  
                    i++;
                }

            }
        }
        public static void DrawingPlinth(Database db, ref Extents2d ext, ref Extents2d extA, ref Extents2d extB, ref Extents2d extC, Point3d startPoint, Point3d startAPoint, Point3d startBPoint, Point3d startCPoint,
string txtStyle, double scale, System.Data.DataRow tr,  string _dwgPath, string plinthCoorPath, string tAPara, string tBPara, string iAPara, string iBPara, string title= "Banaani EX-2",bool isPositive=false)
        {
            List<string> taParas = tAPara.Split('|').ToList();
            List<string> tbParas = tBPara.Split('|').ToList();
            List<string> iaParas = iAPara.Split('|').ToList();
            List<string> ibParas = iBPara.Split('|').ToList();
            if (!DimStyleTool.CheckDimStyleExists(scale))
            {
                DimStyleTool.CreateModifyDimStyle(scale);
            }
            double tSize = 0.15;

            if(scale==80)
                tSize = (2 *  scale) / 1000;
            else if (scale == 100)
                tSize = (2 *  scale) / 1000;
            else
                tSize = (2 * scale) / 1000;

            double lwidth = double.Parse(tr["左墩距"].ToString());
            double side = double.Parse(tr["左边距"].ToString());
            double rside = double.Parse(tr["右边距"].ToString());
            double width = double.Parse(tr["总墩距"].ToString()) + rside+ side;
            double bottomW = double.Parse(tr["底宽"].ToString());
            double topW = double.Parse(tr["顶宽"].ToString());
            double height = double.Parse(tr["总高"].ToString());
            double calculatedHeight = double.Parse(tr["底高"].ToString());
            double plinthHeight = double.Parse(tr["支座距"].ToString());
            string piername = tr["墩号"].ToString();
            string piertype = tr["墩柱类别"].ToString();
            string AString = tr["垫石A"].ToString();
            string BString = tr["垫石B"].ToString();

            string tapara = taParas.Find(item => item.Contains(piername));
            string[] taparas=null;
            if (tapara!=null)
              taparas = tapara.Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':');
            string tbpara = tbParas.Find(item => item.Contains(piername));
            string[] tbparas = null;
            if (tbpara!=null)
              tbparas = tbpara.Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':');
            string iapara = iaParas.Find(item => item.Contains(piername));
            string[] iaparas=null;
            if (iapara!=null)
               iaparas = iapara.Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':');
            string ibpara = ibParas.Find(item => item.Contains(piername));
            string[] ibparas = null;
            if (ibpara!=null)
               ibparas = ibpara.Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':');

            List<double> Alist = new List<double>();
            List<double> Blist = new List<double>();
            for (int i = 0; i < AString.Split('+').Length; i ++)
            {
                string value = AString.Split('+')[i];
                if (value.Contains("*"))
                {
                    int count = int.Parse(value.Split('*')[1]);
                    double length= double.Parse(value.Split('*')[0]);
                    for(int j=0;j< count;j++)
                    {
                        Alist.Add(length);
                    }
                }
                else
                {
                    Alist.Add(double.Parse(value));
                }
            }
            for (int i = 0; i < BString.Split('+').Length; i++)
            {
                string value = BString.Split('+')[i];
                if (value.Contains("*"))
                {
                    int count = int.Parse(value.Split('*')[1]);
                    double length = double.Parse(value.Split('*')[0]);
                    for (int j = 0; j < count; j++)
                    {
                        Blist.Add(length);
                    }
                }
                else
                {
                    Blist.Add(double.Parse(value));
                }
            }
            #region 平面绘制
            string str1 = string.Format("PIER TYPE \"{0}\" FOR {1} OF {2} (PLAN VIEW) ", piertype, piername, title);
            string str2 = "1:" + scale + "@A3";
            TextPloter.PrintScaleDoubleSideTextNew(db, startPoint.Convert2D(0, 13 * tSize), tSize * 1.25, str1, str2, ref ext, 1, Extensions.curFont);
            #region 1.外轮廓绘制
            //1、绘制
            List<Point2d> ptL = new List<Point2d>();
            Point2d pt1 = startPoint.Convert2D(-width * 0.5);
            Point2d pt2 = pt1.Convert2D(0,-bottomW);
            Point2d pt3 = pt2.Convert2D(width);
            Point2d pt4 = pt3.Convert2D(0, bottomW);
            ptL.Add(pt1);
            ptL.Add(pt2);
            ptL.Add(pt3);
            ptL.Add(pt4);
            PolylinePloter.AddPolylineByList(db,ref ext, ptL,"细线",4,true);

            ptL = new List<Point2d>();
            double h = (bottomW - topW) * 0.5;

            ptL = new List<Point2d>();


            Dictionary<string, Dictionary<string, string>> dicA = new Dictionary<string, Dictionary<string, string>>();
            Dictionary<string, string> dicT = new Dictionary<string, string>();

            dicT = new Dictionary<string, string>();
  
            dicT.Add("Bearing", "string");
            dicA.Add("CL", dicT);
            string _blcName = "CL";
            db.CopyBlockFromFile(_dwgPath, _blcName);          
            BlockTool.InsertBlockReference(pt3.Convert3D(0.6 +0.15, 0.5 * h), tSize * 1.6, _blcName, _dwgPath, dicA, null, ref ext);
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(pt4.Convert3D(0.6  + 0.15, -0.5 * h), tSize * 1.6, _blcName, _dwgPath, dicA, null, ref ext);

            dicA = new Dictionary<string, Dictionary<string, string>>();
            dicT = new Dictionary<string, string>();
            dicT.Add("Pier", "string");
            dicA.Add("CL", dicT);           
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(pt4.Convert3D(0.6 + 0.15, -bottomW * 0.5), tSize * 1.6, _blcName, _dwgPath, dicA, null, ref ext);

            DimPloter.AddZYBJ("Ⅰ", pt1.Convert3D(-0.6 - 0.15, -0.25 * h), ref ext, 0.05, tSize, true);
            DimPloter.AddZYBJ("Ⅱ", pt2.Convert3D(-0.6 - 0.15, 0.25 * h), ref ext, 0.05, tSize, true);
            DimPloter.AddZYBJ("Ⅰ", pt4.Convert3D(0.3 + 0.15, -0.25 * h), ref ext, 0.05, tSize, false);
            DimPloter.AddZYBJ("Ⅱ", pt3.Convert3D(0.3 + 0.15, 0.25 * h), ref ext, 0.05, tSize, false);

            PolylinePloter.AddPolyline(db, ref ext, pt1.Convert2D(-0.2, -bottomW*0.5), pt4.Convert2D(0.2, -bottomW * 0.5), 0, 0, 0, 0, "中心线", 5,2.5);
            PolylinePloter.AddPolyline(db, ref ext, pt1.Convert2D(-0.2, -h * 0.5), pt4.Convert2D(0.2, -h * 0.5), 0, 0, 0, 0, "中心线", 5, 2.5);
            PolylinePloter.AddPolyline(db, ref ext, pt2.Convert2D(-0.2, h * 0.5), pt3.Convert2D(0.2, h * 0.5), 0, 0, 0, 0, "中心线", 5, 2.5);


            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(0, tSize * 3), startPoint.Convert2D(0, -bottomW-0.3), 0, 0, 0, 0, "中心线", 5, 2.5);
            dicA = new Dictionary<string, Dictionary<string, string>>();
            dicT = new Dictionary<string, string>();
            dicT.Add("Cross Beam", "string");
            dicA.Add("CL", dicT);
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(startPoint.Convert3D(0, tSize * 3.5), tSize * 2, _blcName, _dwgPath, dicA, null, ref ext);

            #endregion
            #region 垫石绘制
            double hADim = 0.3;
            if (!isPositive)
            {
                
                #region 逆序垫石绘制(默认)
                double len = 0;
                for (int i = 0; i < Alist.Count; i++)
                {
                    len += Alist[i];
                    Point2d ptB = pt4.Convert2D(-len, -h * 0.5);
                    //PolylinePloter.AddPloy4(db, ref ext, ptB.Convert2D(0, 0.5 * 0.5), 0.6 * 0.5, 0.6 * 0.5, 0.5);
                    _blcName = "pPlinthA" + scale;
                    if(scale>40)
                        _blcName = "pPlinth" + scale;
                    dicA = new Dictionary<string, Dictionary<string, string>>();
                    dicT = new Dictionary<string, string>();
                    dicT.Add((i + 1).ToString(), "string");
                    dicA.Add("A", dicT);
                    db.CopyBlockFromFile(_dwgPath, _blcName);
                    BlockTool.InsertBlockReference(ptB.Convert3D(), 1, _blcName, _dwgPath, dicA, null, ref ext);

                    if (iaparas != null)
                    {
                        if (iaparas[1].Contains((i + 1).ToString()))
                        {
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, -0.7 - tSize * 2), scale);
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5).Convert3D(-(Alist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, -0.7 ), scale);
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5).Convert3D(-(Alist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5).Convert3D(-(Alist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, -0.7  - tSize * 2), scale);
                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - (Alist[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.5 * 0.5), (Alist[i + 1] - 0.015 * 2 - 0.6) * 0.5, (Alist[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.5);
                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                        }
                    }

                    else
                    {
                        if (tapara != null)
                        {
                            if (taparas[1].Contains((i + 1).ToString()))
                            {
                                List<string> lst = taparas[1].Split(',').ToList();
                                for (int no = 0; no < lst.Count; no++)
                                {
                                    if (lst[no] == (i + 1).ToString())
                                    {
                                        if (no % 2 == 0)
                                        {
                                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                            //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                        }
                                        else
                                        {
                                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                            //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (i == 0)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            else if (i == 1)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            if (i == Alist.Count - 2)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            else if (i == Alist.Count - 1)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                        }
                    }
                }
                len = 0;
                for (int i = 0; i < Blist.Count; i++)
                {
                    len += Blist[i];
                    Point2d ptB = pt3.Convert2D(-len, h * 0.5);

                    _blcName = "pPlinthB" + scale;
                    if (scale > 40)
                        _blcName = "pPlinth" + scale;
                    dicA = new Dictionary<string, Dictionary<string, string>>();
                    dicT = new Dictionary<string, string>();
                    dicT.Add((i + 1).ToString(), "string");
                    dicA.Add("A", dicT);
                    db.CopyBlockFromFile(_dwgPath, _blcName);
                    BlockTool.InsertBlockReference(ptB.Convert3D(), 1, _blcName, _dwgPath, dicA, null, ref ext);

                    if (ibpara != null)
                    {
                        if (ibparas[1].Contains((i + 1).ToString()))
                        {
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, -0.7 - tSize * 2), scale);
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5).Convert3D(-(Blist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, -0.7), scale);
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5).Convert3D(-(Blist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5).Convert3D(-(Blist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, -0.7 - tSize * 2), scale);
                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - (Blist[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.5 * 0.5), (Blist[i + 1] - 0.015 * 2 - 0.6) * 0.5, (Blist[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.5);
                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                        }
                    }
                    else
                    {
                        if (tbpara != null)
                        {
                            if (tbparas[1].Contains((i + 1).ToString()))
                            {
                                List<string> lst = tbparas[1].Split(',').ToList();
                                for (int no = 0; no < lst.Count; no++)
                                {
                                    if (lst[no] == (i + 1).ToString())
                                    {
                                        if (no % 2 == 0)
                                        {
                                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                            //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                            //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                        }
                                        else
                                        {
                                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                            //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (i == 0)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            else if (i == 1)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            if (i == Blist.Count - 2)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            else if (i == Blist.Count - 1)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                        }
                    }
                }
                #endregion
            }
            else
            {
                #region 正序垫石绘制
                double len = 0;
                for (int i = 0; i < Alist.Count; i++)
                {
                    len += Alist[i];
                    Point2d ptB = pt1.Convert2D(len, -h * 0.5);
                    //PolylinePloter.AddPloy4(db, ref ext, ptB.Convert2D(0, 0.5 * 0.5), 0.6 * 0.5, 0.6 * 0.5, 0.5);
                    _blcName = "pPlinthA" + scale;
                    dicA = new Dictionary<string, Dictionary<string, string>>();
                    dicT = new Dictionary<string, string>();
                    dicT.Add((i + 1).ToString(), "string");
                    dicA.Add("A", dicT);
                    db.CopyBlockFromFile(_dwgPath, _blcName);
                    BlockTool.InsertBlockReference(ptB.Convert3D(), 1, _blcName, _dwgPath, dicA, null, ref ext);

                    if (iaparas != null)
                    {
                        if (iaparas[1].Contains((i + 1).ToString()))
                        {
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, -0.7 - tSize * 2), scale);
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5).Convert3D((Alist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, -0.7), scale);
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5).Convert3D((Alist[i + 1] - 0.015 * 2 -0.6)), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5).Convert3D((Alist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, -0.7 - tSize * 2), scale);
                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 +0.015 + (Alist[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.5 * 0.5), (Alist[i + 1] - 0.015 * 2 - 0.6) * 0.5, (Alist[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.5);
                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                        }
                    }

                    else
                    {
                        if (tapara != null)
                        {
                            if (taparas[1].Contains((i + 1).ToString()))
                            {
                                List<string> lst = taparas[1].Split(',').ToList();
                                for (int no = 0; no < lst.Count; no++)
                                {
                                    if (lst[no] == (i + 1).ToString())
                                    {
                                        if (no % 2 == 0)
                                        {
                                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                            //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 +0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                        }
                                        else
                                        {
                                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-(0.6 * 0.5 + 0.015), 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                            //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (i == 0)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5+0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            else if (i == 1)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-(0.6 * 0.5 + 0.015), 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            if (i == Alist.Count - 2)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5+0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            else if (i == Alist.Count - 1)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-(0.6 * 0.5 + 0.015), 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                        }
                    }
                }
                len = 0;
                for (int i = 0; i < Blist.Count; i++)
                {
                    len += Blist[i];
                    Point2d ptB = pt2.Convert2D(len, h * 0.5);

                    _blcName = "pPlinthB" + scale;
                    dicA = new Dictionary<string, Dictionary<string, string>>();
                    dicT = new Dictionary<string, string>();
                    dicT.Add((i + 1).ToString(), "string");
                    dicA.Add("A", dicT);
                    db.CopyBlockFromFile(_dwgPath, _blcName);
                    BlockTool.InsertBlockReference(ptB.Convert3D(), 1, _blcName, _dwgPath, dicA, null, ref ext);

                    if (ibpara != null)
                    {
                        if (ibparas[1].Contains((i + 1).ToString()))
                        {
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, -0.7 - tSize * 2), scale);
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5).Convert3D((Blist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, -0.7), scale);
                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5).Convert3D((Blist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5).Convert3D((Blist[i + 1] - 0.015 * 2 - 0.6)), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, -0.7 - tSize * 2), scale);
                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + (Blist[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.5 * 0.5), (Blist[i + 1] - 0.015 * 2 - 0.6) * 0.5, (Blist[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.5);
                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                        }
                    }
                    else
                    {
                        if (tbpara != null)
                        {
                            if (tbparas[1].Contains((i + 1).ToString()))
                            {
                                List<string> lst = tbparas[1].Split(',').ToList();
                                for (int no = 0; no < lst.Count; no++)
                                {
                                    if (lst[no] == (i + 1).ToString())
                                    {
                                        if (no % 2 == 0)
                                        {
                                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                            //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                            //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                        }
                                        else
                                        {
                                            DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-(0.6 * 0.5 + 0.015), 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                            //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                            //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                            HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (i == 0)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 +0.015 +0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            else if (i == 1)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-(0.6 * 0.5 + 0.015), 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            if (i == Blist.Count - 2)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 +0.015, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5 - 0.015, 0.5 * 0.5), ptB.Convert3D(-0.6 * 0.5 - 0.015 - 0.5, 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.25 ), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                            else if (i == Blist.Count - 1)
                            {
                                DimPloter.DimAli(db, ref ext, ptB.Convert3D(-0.6 * 0.5, 0.5 * 0.5), ptB.Convert3D(-(0.6 * 0.5 + 0.015), 0.5 * 0.5), ptB.Convert2D(-0.6 * 0.5, 0).Convert3D(0, 0.3 - tSize * 2), scale);
                                //DimPloter.DimAli(db, ref ext, ptB.Convert3D(0.6 * 0.5 + 0.015, 0.5 * 0.5), ptB.Convert3D(0.6 * 0.5 + 0.015 + 0.5, 0.5 * 0.5), ptB.Convert2D(0.6 * 0.5, 0).Convert3D(0, 0.3), scale);
                                //Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25 * 0.5), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.25), 0.5 * 0.5, 0.5 * 0.5, 0.25);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                            }
                        }
                    }
                }
                #endregion
            }
            #endregion

            #region //2、标注
            #region 外轮廓


            //左侧
            DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt2.Convert3D(), pt1.Convert3D(-0.3), scale);

            //右侧
            DimPloter.DimAli(db, ref ext, pt3.Convert3D(0, 0.5 * h ), pt4.Convert3D(0,-bottomW * 0.5), pt4.Convert3D(0.6), scale);
            DimPloter.DimAli(db, ref ext, pt4.Convert3D(0, -0.5 * h ), pt4.Convert3D(0, -bottomW * 0.5), pt4.Convert3D(0.6), scale);

            DimPloter.DimAli(db, ref ext, pt3.Convert3D(0, 0.5 * h), pt4.Convert3D(0, -0.5 * h), pt4.Convert3D(1.1), scale, "null");
            int pierNo = int.Parse(System.Text.RegularExpressions.Regex.Replace(piername, @"[^0-9]+", "").ToString());
            string stN = piername.Replace(pierNo.ToString(), "") + (pierNo - 1);
            string edN = piername.Replace(pierNo.ToString(), "") + (pierNo + 1);
            TextPloter.PlotText(db, ref ext, pt3.Convert3D(0.6+5*tSize, 0.5 * h - 0.2), edN, 1, tSize);
            TextPloter.PlotText(db, ref ext, pt4.Convert3D(0.6 + 5 * tSize, -0.5 * h+0.05), stN, 1, tSize);
            TextPloter.PlotText(db, ref ext, pt4.Convert3D(0.6 + 5* tSize, -bottomW * 0.5), piername, 1, tSize);

            //上部
            DimPloter.DimAli(db, ref ext, pt4.Convert3D(-rside), pt1.Convert3D(side), pt1.Convert3D(0, 10.5*tSize), scale);

            DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(width * 0.5), pt1.Convert3D(0, 8 * tSize), scale);
            DimPloter.DimAli(db, ref ext,  pt1.Convert3D(width * 0.5), pt4.Convert3D(), pt1.Convert3D(0,  8 * tSize), scale);
            #endregion
            double len1 = 0;
            double len2 = 0;
            #region 垫石
            if (!isPositive)
            {
                for (int i = 0; i < Alist.Count; i++)
                {

                    if (i > 0)
                        len1 += Alist[i - 1];
                    len2 += Alist[i];
                    if (i == 0)
                        DimPloter.DimAli(db, ref ext, pt4.Convert3D(), pt4.Convert3D(-len2), pt1.Convert3D(0, 5.5 * tSize), scale);
                    else
                    {
                        DimPloter.DimAli(db, ref ext, pt4.Convert3D(-len2), pt4.Convert3D(-len1), pt1.Convert3D(0, 5.5 * tSize), scale);
                    }
                    if (i == Alist.Count - 1)
                        DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt4.Convert3D(-len2), pt1.Convert3D(0, 5.5 * tSize), scale);
                    //TextPloter.PlotText(db, ref ext, pt4.Convert3D(-len2-0.4, 0.1), txt, 1, 0.15);


                }
                len1 = 0;
                len2 = 0;
                for (int i = 0; i < Blist.Count; i++)
                {

                    if (i > 0)
                        len1 += Blist[i - 1];
                    len2 += Blist[i];
                    if (i == 0)
                        DimPloter.DimAli(db, ref ext, pt3.Convert3D(), pt3.Convert3D(-len2), pt2.Convert3D(0, -4 * tSize), scale);
                    else
                    {
                        DimPloter.DimAli(db, ref ext, pt3.Convert3D(-len2), pt3.Convert3D(-len1), pt2.Convert3D(0, -4 * tSize), scale);
                    }
                    if (i == Blist.Count - 1)
                        DimPloter.DimAli(db, ref ext, pt2.Convert3D(), pt3.Convert3D(-len2), pt2.Convert3D(0, -4 * tSize), scale);

                }
            }
            else
            {
                for (int i = 0; i < Alist.Count; i++)
                {

                    if (i > 0)
                        len1 += Alist[i - 1];
                    len2 += Alist[i];
                    if (i == 0)
                        DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(len2), pt1.Convert3D(0, 5.5 * tSize), scale);
                    else
                    {
                        DimPloter.DimAli(db, ref ext, pt1.Convert3D(len2), pt1.Convert3D(len1), pt1.Convert3D(0, 5.5 * tSize), scale);
                    }
                    if (i == Alist.Count - 1)
                        DimPloter.DimAli(db, ref ext, pt4.Convert3D(), pt1.Convert3D(len2), pt1.Convert3D(0, 5.5 * tSize), scale);
                    //TextPloter.PlotText(db, ref ext, pt4.Convert3D(-len2-0.4, 0.1), txt, 1, 0.15);


                }
                len1 = 0;
                len2 = 0;
                for (int i = 0; i < Blist.Count; i++)
                {

                    if (i > 0)
                        len1 += Blist[i - 1];
                    len2 += Blist[i];
                    if (i == 0)
                        DimPloter.DimAli(db, ref ext, pt2.Convert3D(), pt2.Convert3D(len2), pt2.Convert3D(0, -4 * tSize), scale);
                    else
                    {
                        DimPloter.DimAli(db, ref ext, pt2.Convert3D(len2), pt2.Convert3D(len1), pt2.Convert3D(0, -4 * tSize), scale);
                    }
                    if (i == Blist.Count - 1)
                        DimPloter.DimAli(db, ref ext, pt3.Convert3D(), pt2.Convert3D(len2), pt2.Convert3D(0, -4 * tSize), scale);

                }
            }
            #endregion

            #endregion

            #endregion

            #region 立面I绘制
            CreateAB(db, ref extA, startAPoint, Extensions.curFont, scale, tr, Alist,_dwgPath, plinthCoorPath, iaparas, ibparas, taparas, tbparas, title, "Ⅰ-Ⅰ",isPositive);
            #endregion

            #region 立面II绘制
            CreateAB(db, ref extB, startBPoint, Extensions.curFont, scale, tr, Blist, _dwgPath, plinthCoorPath, iaparas, ibparas, taparas, tbparas, title,"Ⅱ-Ⅱ", isPositive);
            #endregion

            CreateBS(db, ref extC, startCPoint, Extensions.curFont, scale, tr, _dwgPath);
        }

        public static void CreateAB(Database db, ref Extents2d ext, Point3d startPoint,
string txtStyle, double scale, System.Data.DataRow tr, List<double> lst, string _dwgPath, string plinthCoorPath, string[] iaparas, string[] ibparas, string[] taparas, string[] tbparas, string location = "Banaani EX-2", string title = "Ⅰ-Ⅰ", bool isPositive = false)
        {
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WeChat Files\wxid_1fmp3vdht5sl22\FileStorage\File\2021-12\P-295-P-335垫石坐标.csv");
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\Banani EX-2 垫石坐标(1).csv");
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\Banani EX-1 垫石坐标.csv");
            System.Data.DataTable dt = CVSTools.OpenCSV(plinthCoorPath);
            DataView dv0 = dt.DefaultView;
            dt = dv0.ToTable(true, new string[] { "Pier", "Side", "PlinthNo", "East", "North", "Height", "H0" });

            double tSize = 0.15;
            if (scale == 80)
                tSize = (2 * scale) / 1000;
            else if (scale == 100)
                tSize = (2 * scale) / 1000;
            else
                tSize = (2 * scale) / 1000;
            //double width = double.Parse(tr["总墩距"].ToString());
            double lwidth = double.Parse(tr["左墩距"].ToString());
            double side = double.Parse(tr["左边距"].ToString());
            double rside = double.Parse(tr["右边距"].ToString());
            double width = double.Parse(tr["总墩距"].ToString()) + rside + side;
            double bottomW = double.Parse(tr["底宽"].ToString());
            double topW = double.Parse(tr["顶宽"].ToString());
            double height = double.Parse(tr["总高"].ToString());
            double calculatedHeight = double.Parse(tr["底高"].ToString());
            double plinthHeight = double.Parse(tr["支座距"].ToString());
            string piername = tr["墩号"].ToString();
            string piertype = tr["墩柱类别"].ToString();
            //string AString = tr["垫石A"].ToString();
            //string BString = tr["垫石B"].ToString();
            double radius = 0.2;

            double pierW = 1.2;

            DataRow[] drsA = dt.Select("Pier='" + piername + "' and Side='A' and PlinthNo like '%-1'");
            if (title == "Ⅰ-Ⅰ")
                drsA = dt.Select("Pier='" + piername + "' and Side='A' and PlinthNo like '%-1'");
            else
                drsA = dt.Select("Pier='" + piername + "' and Side='B' and PlinthNo like '%-1'");

            System.Data.DataTable dt0 = dt.Clone();
            foreach (DataRow item in drsA)
            {
                dt0.Rows.Add(item.ItemArray);
            }
            Dictionary<string, Dictionary<string, string>> dicA = new Dictionary<string, Dictionary<string, string>>();
            Dictionary<string, string> dicT = new Dictionary<string, string>();

            dicT = new Dictionary<string, string>();
            string _blcName = "";
            #region 1.外轮廓绘制

            string str1 = title + " FOR " + piername + " OF " + location + "";
            string str2 = "1:" + scale + "@A3";
            TextPloter.PrintScaleDoubleSideTextNew(db, startPoint.Convert2D(0, 18 * tSize), tSize * 1.25, str1, str2, ref ext, 1, Extensions.curFont);
            //1、绘制
            List<Point2d> ptL = new List<Point2d>();
            Point2d pt1 = startPoint.Convert2D(-width * 0.5);
            Point2d pt2 = pt1.Convert2D(0, -height + radius);
            Point2d pt3 = pt2.Convert2D(width);
            Point2d pt4 = pt3.Convert2D(0, height - radius);
            Point2d pt0 = pt4;// pt3.Convert2D(0, -radius);
            if (isPositive)
                pt0 = pt2;
            ptL.Add(pt2);
            ptL.Add(pt1);
            ptL.Add(pt4);
            ptL.Add(pt3);
            PolylinePloter.AddPolylineByList(db, ref ext, ptL, "细线", 4, false);

            PolylinePloter.CreateArc(db, ref ext, pt2.Convert3D(radius), radius, 180, 270);
            PolylinePloter.CreateArc(db, ref ext, pt3.Convert3D(-radius), radius, 270, 0);
            PolylinePloter.AddPolyline(db, ref ext, pt2.Convert2D(radius, -radius), pt3.Convert2D(-radius, -radius), 0, 0, 0, 0, "细线", 4);


            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(-3.5 * 0.5 - radius * 2, -height), startPoint.Convert2D(-3.5 * 0.5 - radius, -height - 0.5), 0, 0, 0, 0, "细线", 4);
            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(3.5 * 0.5 + radius * 2, -height), startPoint.Convert2D(3.5 * 0.5 + radius, -height - 0.5), 0, 0, 0, 0, "细线", 4);
            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(-3.5 * 0.5 - radius * 2, -height), startPoint.Convert2D(-3.5 * 0.5, -height - 0.5), 0, 0, 0, 0, "细线", 4);
            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(3.5 * 0.5 + radius * 2, -height), startPoint.Convert2D(3.5 * 0.5, -height - 0.5), 0, 0, 0, 0, "细线", 4);
            PolylinePloter.CreateBreakLine(db, ref ext, startPoint.Convert2D(-3.5 * 0.5 - radius * 2, -height - 0.5), startPoint.Convert2D(3.5 * 0.5 + radius * 2, -height - 0.5), 1);


            _blcName = "CL";

            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(0, 7.5 * tSize), startPoint.Convert2D(0, -bottomW), 0, 0, 0, 0, "中心线", 5, 2.5);
            dicA = new Dictionary<string, Dictionary<string, string>>();
            dicT = new Dictionary<string, string>();
            dicT.Add("Pier", "string");
            dicA.Add("CL", dicT);
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(startPoint.Convert3D(0, 7.5 * tSize), tSize * 2, _blcName, _dwgPath, dicA, null, ref ext);

            //2、标注
            if (!DimStyleTool.CheckDimStyleExists(scale))
            {
                DimStyleTool.CreateModifyDimStyle(scale);
            }

            #endregion

            double len = 0;
            if (!isPositive)
            {

                #region 逆序垫石绘制
                for (int i = 0; i < lst.Count; i++)
                {
                    len += lst[i];
                    Point2d ptB = pt0.Convert2D(-len);

                    _blcName = "vPlinth" + scale;
                    Dictionary<string, Dictionary<string, string>> dicb = new Dictionary<string, Dictionary<string, string>>();
                    dicA = new Dictionary<string, Dictionary<string, string>>();
                    dicT = new Dictionary<string, string>();
                    dicT.Add((i + 1).ToString(), "string");
                    dicA.Add("A", dicT);
                    if (i < drsA.Length)
                    {
                        DataRow[] dr = dt0.Select("PlinthNo like '" + (i + 1) + "-%'");
                        dicT = new Dictionary<string, string>();
                        dicT.Add(double.Parse(dr[0]["Height"].ToString()).ToString("0.000"), "double");
                        dicb.Add("距离1", dicT);
                    }
                    db.CopyBlockFromFile(_dwgPath, _blcName);
                    BlockTool.InsertBlockReference(ptB.Convert3D(0.3, -0.454), 1, _blcName, _dwgPath, dicA, dicb, ref ext);

                    //挡块
                    if (title == "Ⅰ-Ⅰ")
                    {
                        if (iaparas != null)
                        {
                            if (iaparas[1].Contains((i + 1).ToString()))
                            {
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.6), (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.6);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                if (i == 0)
                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - (lst[i + 1] - 0.015 * 2 - 0.6) * 0.8, 0), ptB.Convert2D(-0.6 * 0.5 - 0.015 - (lst[i + 1] - 0.015 * 2 - 0.6) * 0.8 + 0.5, -0.4), "Concrete buffer", tSize, scale);
                            }
                        }
                        else
                        {
                            if (taparas != null)
                            {
                                if (taparas[1].Contains((i + 1).ToString()))
                                {
                                    List<string> lt = taparas[1].Split(',').ToList();
                                    for (int no = 0; no < lt.Count; no++)
                                    {
                                        if (lt[no] == (i + 1).ToString())
                                        {
                                            if (no % 2 == 0)
                                            {
                                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                            }
                                            else
                                            {
                                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                                if (no == 1)
                                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), ptB.Convert2D(0.6 * 0.5 + 0.5, -0.4), "Concrete buffer", tSize, scale);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (i == 0)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                                else if (i == 1)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);

                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), ptB.Convert2D(0.6 * 0.5 + 0.5, -0.4), "Concrete buffer", tSize, scale);
                                }
                                if (i == lst.Count - 2)
                                {

                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                                else if (i == lst.Count - 1)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (ibparas != null)
                        {
                            if (ibparas[1].Contains((i + 1).ToString()))
                            {
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.6), (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.6);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                if (i == 0)
                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - (lst[i + 1] - 0.015 * 2 - 0.6) * 0.8, 0), ptB.Convert2D(-0.6 * 0.5 - 0.015 - (lst[i + 1] - 0.015 * 2 - 0.6) * 0.8 + 0.5, -0.4), "Concrete buffer", tSize, scale);
                            }
                        }
                        else
                        {
                            if (tbparas != null)
                            {
                                if (tbparas[1].Contains((i + 1).ToString()))
                                {
                                    List<string> lt = tbparas[1].Split(',').ToList();
                                    for (int no = 0; no < lt.Count; no++)
                                    {
                                        if (lt[no] == (i + 1).ToString())
                                        {
                                            if (no % 2 == 0)
                                            {
                                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                            }
                                            else
                                            {
                                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                                if (no == 1)
                                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), ptB.Convert2D(0.6 * 0.5 + 0.5, -0.4), "Concrete buffer", tSize, scale);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (i == 0)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                                else if (i == 1)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0), ptB.Convert2D(0.6 * 0.5 + 0.5, -0.4), "Concrete buffer", tSize, scale);
                                    //DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), ptB.Convert2D(0.6 * 0.5 + 1, 0.5), "Concrete buffer", tSize * 1.5, scale);
                                }
                                if (i == lst.Count - 2)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-0.6 * 0.5 - 0.015 - 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                                else if (i == lst.Count - 1)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                            }
                        }
                    }
                }

                #endregion

                #region 
                //左侧
                DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(0,-height), pt1.Convert3D(-0.3), scale);
                //DimPloter.DimAli(db, ref ext, pt1.Convert3D(0, -h), pt1.Convert3D(), pt1.Convert3D(-0.5), scale);
                //DimPloter.DimAli(db, ref ext, pt0.Convert3D(-width), pt1.Convert3D(0, -h), pt1.Convert3D(-0.5), scale);

                //上部
                DimPloter.DimAli(db, ref ext, pt4.Convert3D(), pt1.Convert3D(), pt1.Convert3D(0, 15 * tSize), scale);
                //DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(side), pt1.Convert3D(0, 1.1), scale);
                //DimPloter.DimAli(db, ref ext, pt4.Convert3D(), pt4.Convert3D(), pt1.Convert3D(0, 1.1), scale);
                DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(width * 0.5), pt1.Convert3D(0, 12.5 * tSize), scale);
                DimPloter.DimAli(db, ref ext, pt1.Convert3D(width * 0.5), pt4.Convert3D(), pt1.Convert3D(0, 12.5 * tSize), scale);
                //DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(radius), pt1.Convert3D(0, 0.8), scale);
                //DimPloter.DimAli(db, ref ext, pt4.Convert3D(-radius), pt4.Convert3D(), pt1.Convert3D(0, 0.8), scale);
                double len1 = 0;
                double len2 = 0;
                #region 垫石
                for (int i = 0; i < lst.Count; i++)
                {

                    if (i > 0)
                        len1 += lst[i - 1];
                    len2 += lst[i];
                    if (i == 0)
                        DimPloter.DimAli(db, ref ext, pt4.Convert3D(), pt4.Convert3D(-len2), pt1.Convert3D(0, 10 * tSize), scale);
                    else
                    {
                        DimPloter.DimAli(db, ref ext, pt4.Convert3D(-len2), pt4.Convert3D(-len1), pt1.Convert3D(0, 10 * tSize), scale);
                    }
                    if (i == lst.Count - 1)
                        DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt4.Convert3D(-len2), pt1.Convert3D(0, 10 * tSize), scale);

                }
                #endregion
                #endregion
            }
            else
            {
                #region 正序垫石绘制
                for (int i = 0; i < lst.Count; i++)
                {
                    len += lst[i];
                    Point2d ptB = pt0.Convert2D(len);

                    _blcName = "vPlinth" + scale;
                    Dictionary<string, Dictionary<string, string>> dicb = new Dictionary<string, Dictionary<string, string>>();
                    dicA = new Dictionary<string, Dictionary<string, string>>();
                    dicT = new Dictionary<string, string>();
                    dicT.Add((i + 1).ToString(), "string");
                    dicA.Add("A", dicT);
                    if (i < drsA.Length)
                    {
                        DataRow[] dr = dt0.Select("PlinthNo like '" + (i + 1) + "-%'");
                        dicT = new Dictionary<string, string>();
                        dicT.Add(double.Parse(dr[0]["Height"].ToString()).ToString("0.000"), "double");
                        dicb.Add("距离1", dicT);
                    }
                    db.CopyBlockFromFile(_dwgPath, _blcName);
                    BlockTool.InsertBlockReference(ptB.Convert3D(0.3, -0.454), 1, _blcName, _dwgPath, dicA, dicb, ref ext);

                    //挡块
                    if (title == "Ⅰ-Ⅰ")
                    {
                        if (iaparas != null)
                        {
                            if (iaparas[1].Contains((i + 1).ToString()))
                            {
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 +(lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.6), (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.6);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                if (i == 0)
                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 +(lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0), ptB.Convert2D(0.6 * 0.5 + 0.015 + (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5 + 0.5, -0.4), "Concrete buffer", tSize, scale);
                            }
                        }
                        else
                        {
                            if (taparas != null)
                            {
                                if (taparas[1].Contains((i + 1).ToString()))
                                {
                                    List<string> lt = taparas[1].Split(',').ToList();
                                    for (int no = 0; no < lt.Count; no++)
                                    {
                                        if (lt[no] == (i + 1).ToString())
                                        {
                                            if (no % 2 == 0)
                                            {
                                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                            }
                                            else
                                            {
                                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                                if (no == 1)
                                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0), ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5) + 0.5, -0.4), "Concrete buffer", tSize, scale);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (i == 0)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 +0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                                else if (i == 1)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);

                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0), ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5 )+0.5, -0.4), "Concrete buffer", tSize, scale);
                                }
                                if (i == lst.Count - 2)
                                {

                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 +0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                                else if (i == lst.Count - 1)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (ibparas != null)
                        {
                            if (ibparas[1].Contains((i+1).ToString()))
                            {
                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 +(lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.6), (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, (lst[i + 1] - 0.015 * 2 - 0.6) * 0.5, 0.6);
                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                if (i == 0)
                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + (lst[i + 1] - 0.015 * 2 - 0.6) * 0.8, 0), ptB.Convert2D(0.6 * 0.5 + 0.015 + (lst[i + 1] - 0.015 * 2 - 0.6) * 0.8 + 0.5, -0.4), "Concrete buffer", tSize, scale);
                            }
                        }
                        else
                        {
                            if (tbparas != null)
                            {
                                if (tbparas[1].Contains((i + 1).ToString()))
                                {
                                    List<string> lt = tbparas[1].Split(',').ToList();
                                    for (int no = 0; no < lt.Count; no++)
                                    {
                                        if (lt[no] == (i + 1).ToString())
                                        {
                                            if (no % 2 == 0)
                                            {
                                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                            }
                                            else
                                            {
                                                Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                                HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                                if (no == 1)
                                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0), ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5) + 0.5, -0.4), "Concrete buffer", tSize, scale);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (i == 0)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015+ 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                                else if (i == 1)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                    DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0), ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5) + 0.5, -0.4), "Concrete buffer", tSize, scale);
                                    //DimPloter.AddMLeader(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), ptB.Convert2D(0.6 * 0.5 + 1, 0.5), "Concrete buffer", tSize * 1.5, scale);
                                }
                                if (i == lst.Count - 2)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(0.6 * 0.5 + 0.015 + 0.5 * 0.5, 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                                else if (i == lst.Count - 1)
                                {
                                    Polyline pl = PolylinePloter.GetPLAddPloy4(db, ref ext, ptB.Convert2D(-(0.6 * 0.5 + 0.015 + 0.5 * 0.5), 0.6), 0.5 * 0.5, 0.5 * 0.5, 0.6);
                                    HatchPloter.HatchEnity(HostApplicationServices.WorkingDatabase, "ANSI31", 0.04, 0, pl.ObjectId);
                                }
                            }
                        }
                    }
                }

                #endregion

                #region 
                //左侧
                DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(0,-height), pt1.Convert3D(-0.3), scale);
                //DimPloter.DimAli(db, ref ext, pt1.Convert3D(0, -h), pt1.Convert3D(), pt1.Convert3D(-0.5), scale);
                //DimPloter.DimAli(db, ref ext, pt0.Convert3D(-width), pt1.Convert3D(0, -h), pt1.Convert3D(-0.5), scale);

                //上部
                DimPloter.DimAli(db, ref ext, pt4.Convert3D(), pt1.Convert3D(), pt1.Convert3D(0, 15 * tSize), scale);
                //DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(side), pt1.Convert3D(0, 1.1), scale);
                //DimPloter.DimAli(db, ref ext, pt4.Convert3D(), pt4.Convert3D(), pt1.Convert3D(0, 1.1), scale);
                DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(width * 0.5), pt1.Convert3D(0, 12.5 * tSize), scale);
                DimPloter.DimAli(db, ref ext, pt1.Convert3D(width * 0.5), pt4.Convert3D(), pt1.Convert3D(0, 12.5 * tSize), scale);
                //DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(radius), pt1.Convert3D(0, 0.8), scale);
                //DimPloter.DimAli(db, ref ext, pt4.Convert3D(-radius), pt4.Convert3D(), pt1.Convert3D(0, 0.8), scale);
                double len1 = 0;
                double len2 = 0;
                #region 垫石
                for (int i = 0; i < lst.Count; i++)
                {

                    if (i > 0)
                        len1 += lst[i - 1];
                    len2 += lst[i];
                    if (i == 0)
                        DimPloter.DimAli(db, ref ext, pt1.Convert3D(), pt1.Convert3D(len2), pt1.Convert3D(0, 10 * tSize), scale);
                    else
                    {
                        DimPloter.DimAli(db, ref ext, pt1.Convert3D(len2), pt1.Convert3D(len1), pt1.Convert3D(0, 10 * tSize), scale);
                    }
                    if (i == lst.Count - 1)
                        DimPloter.DimAli(db, ref ext, pt4.Convert3D(), pt1.Convert3D(len2), pt1.Convert3D(0, 10 * tSize), scale);

                }
                #endregion
                #endregion
            }
        }

        public static void CreateBS(Database db, ref Extents2d ext, Point3d startPoint,
string txtStyle, double scale, System.Data.DataRow tr,  string _dwgPath)
        {
            double tSize = 0.15;
            if (scale == 80)
                tSize = (2 * scale) / 1000;
            else if (scale == 100)
                tSize = (2 * scale) / 1000;
            else
                tSize = (2 * scale) / 1000;

            double bottomW = double.Parse(tr["底宽"].ToString());
            double topW = double.Parse(tr["顶宽"].ToString());
            double height = double.Parse(tr["总高"].ToString());
            double calculatedHeight = double.Parse(tr["底高"].ToString());
            double plinthHeight = double.Parse(tr["支座距"].ToString());
            string piername = tr["墩号"].ToString();
            string piertype = tr["墩柱类别"].ToString();
            double h = (height - calculatedHeight);
            double w = (bottomW - topW)*0.5;
            double radius = 0.2;

            double pierW = 1.2;
            int pierNo = int.Parse(System.Text.RegularExpressions.Regex.Replace(piername, @"[^0-9]+", "").ToString());
            string stN = piername.Replace(pierNo.ToString(), "") + (pierNo - 1);
            string edN = piername.Replace(pierNo.ToString(), "") + (pierNo + 1);
            Dictionary<string, Dictionary<string, string>> dicA = new Dictionary<string, Dictionary<string, string>>();
            Dictionary<string, string> dicT = new Dictionary<string, string>();

            dicT = new Dictionary<string, string>();
            string _blcName = "";
            #region 1.外轮廓绘制
           
            string str1 = string.Format("PIER TYPE \"{0}\" (SIDE VIEW) ", piertype);
            string str2 = "1:" + scale + "@A3";
            TextPloter.PrintScaleDoubleSideTextNew(db, startPoint.Convert2D(0, 1.3 + 5 * tSize), tSize * 1.25, str1, str2, ref ext, 1, Extensions.curFont);
            Line2d line = new Line2d(startPoint.Convert2D(),startPoint.Convert2D(0,-height));
            //1、绘制
            List<Point2d> ptL = new List<Point2d>();
            Point2d pt1 = startPoint.Convert2D(-bottomW * 0.5);
            Point2d pt2 = pt1.Convert2D(0, -height + radius);
            Point2d pt3 = pt2.Convert2D(bottomW);
            Point2d pt4 = pt3.Convert2D(0, height - radius);
            //Point2d pt0 = pt4;// pt3.Convert2D(0, -radius);
            ptL.Add(pt2);
            ptL.Add(pt1);
            ptL.Add(pt4);
            ptL.Add(pt3);
            PolylinePloter.AddPolylineByList(db, ref ext, ptL, "细线", 4, false);

            PolylinePloter.CreateArc(db, ref ext, pt2.Convert3D(radius), radius, 180, 270);
            PolylinePloter.CreateArc(db, ref ext, pt3.Convert3D(-radius), radius, 270, 0);
            PolylinePloter.AddPolyline(db, ref ext, pt2.Convert2D(radius, -radius), pt3.Convert2D(-radius, -radius), 0, 0, 0, 0, "细线", 4);


            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(-bottomW * 0.5+radius, -height), startPoint.Convert2D(-bottomW * 0.5 + radius, -height - 0.3), 0, 0, 0, 0, "细线", 4);
            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(bottomW * 0.5 - radius, -height), startPoint.Convert2D(bottomW * 0.5 - radius, -height - 0.3), 0, 0, 0, 0, "细线", 4);
            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(-bottomW * 0.5 + radius, -height), startPoint.Convert2D(-bottomW * 0.5 + radius+ radius*0.5, -height - 0.3), 0, 0, 0, 0, "细线", 4);
            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(bottomW * 0.5 - radius, -height), startPoint.Convert2D(bottomW * 0.5 - radius - radius * 0.5, -height - 0.3), 0, 0, 0, 0, "细线", 4);

            //PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(-topW * 0.6, -height), startPoint.Convert2D(-topW * 0.6, -height - 0.3), 0, 0, 0, 0, "细线", 4);
            //PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(topW * 0.6, -height), startPoint.Convert2D(topW * 0.6, -height - 0.3), 0, 0, 0, 0, "细线", 4);

            PolylinePloter.CreateBreakLine(db, ref ext, startPoint.Convert2D(-topW * 0.6-0.5, -height-0.3), startPoint.Convert2D(topW * 0.6+0.5, -height - 0.3), 1);

            _blcName = "CL";
            Point3d pt = GeTools.MidPoint(pt1.Convert3D(), startPoint.Convert3D());
            PolylinePloter.AddPolyline(db, ref ext, pt.Convert2D(), pt.Convert2D(0,h+0.5), 0, 0, 0, 0, "中心线", 5, 2.5);
            dicA = new Dictionary<string, Dictionary<string, string>>();
            dicT = new Dictionary<string, string>();
            dicT.Add("Bearing", "string");
            dicA.Add("CL", dicT);
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(pt.Convert3D(-tSize * 2, h + 0.5), tSize * 2, _blcName, _dwgPath, dicA, null, ref ext);
            _blcName = "bearP";         
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(pt.Convert3D(), 1, _blcName, _dwgPath, null, null, ref ext);

            _blcName = "CL";
            PolylinePloter.AddPolyline(db, ref ext, startPoint.Convert2D(0, 0.5), startPoint.Convert2D(0, -height-0.5), 0, 0, 0, 0, "中心线", 5, 2.5);
            dicA = new Dictionary<string, Dictionary<string, string>>();
            dicT = new Dictionary<string, string>();
            dicT.Add("Pier", "string");
            dicA.Add("CL", dicT);
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(startPoint.Convert3D(-tSize*0.5, 0.5), tSize * 2, _blcName, _dwgPath, dicA, null, ref ext);

            _blcName = "CL";
            Point3d pt0 = GeTools.MidPoint(startPoint.Convert3D(), pt4.Convert3D());
            PolylinePloter.AddPolyline(db, ref ext, pt0.Convert2D(), pt0.Convert2D(0, h + 0.5), 0, 0, 0, 0, "中心线", 5, 2.5);
            dicA = new Dictionary<string, Dictionary<string, string>>();
            dicT = new Dictionary<string, string>();
            dicT.Add("Bearing", "string");
            dicA.Add("CL", dicT);
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(pt0.Convert3D(0, h + 0.5), tSize * 2, _blcName, _dwgPath, dicA, null, ref ext);

            _blcName = "bearP";
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(pt0.Convert3D(), 1, _blcName, _dwgPath, null, null, ref ext);

            _blcName = "PNO";
            dicA = new Dictionary<string, Dictionary<string, string>>();
            dicT = new Dictionary<string, string>();
            dicT.Add(stN, "string");
            dicA.Add("ST", dicT);
            dicT = new Dictionary<string, string>();
            dicT.Add(piername, "string");
            dicA.Add("NO", dicT);
            dicT = new Dictionary<string, string>();
            dicT.Add(edN, "string");
            dicA.Add("ED", dicT);
            db.CopyBlockFromFile(_dwgPath, _blcName);
            BlockTool.InsertBlockReference(startPoint.Convert3D(0, -height - 0.5), 1*scale/80.0, _blcName, _dwgPath, dicA, null, ref ext);
            //2、标注
            if (!DimStyleTool.CheckDimStyleExists(scale))
            {
                DimStyleTool.CreateModifyDimStyle(scale);
            }

            #endregion
            #region 垫石绘制

            #endregion

            #region 
            //左侧
            DimPloter.DimRotated(db, ref ext, pt1.Convert3D(), pt1.Convert3D(0,-height), startPoint.Convert3D(-bottomW*0.5-0.3), scale, 90);
            //DimPloter.DimRotated(db, ref ext, pt1.Convert3D(), pt4.Convert3D(), startPoint.Convert3D(-bottomW * 0.5 - 0.5), scale, 90);
            //DimPloter.DimRotated(db, ref ext, pt4.Convert3D(), pt8.Convert3D(), startPoint.Convert3D(-bottomW * 0.5 - 0.5), scale, 90);

            //上部
            DimPloter.DimRotated(db, ref ext, pt1.Convert3D(), pt4.Convert3D(), startPoint.Convert3D(0, 1 + 2 * tSize), scale);
            //DimPloter.DimRotated(db, ref ext, pt2.Convert3D(), pt6.Convert3D(), startPoint.Convert3D(0, 1), scale);
            //DimPloter.DimRotated(db, ref ext, pt2.Convert3D(), pt15.Convert3D(), startPoint.Convert3D(0, 1), scale);
            //DimPloter.DimRotated(db, ref ext, pt11.Convert3D(), pt15.Convert3D(), startPoint.Convert3D(0, 1), scale);


            DimPloter.DimRotated(db, ref ext, pt.Convert3D(), startPoint.Convert3D(), startPoint.Convert3D(0, 0.7 + 2 * tSize), scale);
            DimPloter.DimRotated(db, ref ext, pt0.Convert3D(), startPoint.Convert3D(), startPoint.Convert3D(0, 0.7 + 2 * tSize), scale);
            #endregion
        }
    }
}
